import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'
import Shop from '@/views/Shop'
import Cart from '@/views/Cart'
import Login from '@/components/Login'
import User from '@/views/User'
import Component from '@/components/Component'
import Shoplist from '@/components/ShopList'
import Coupon from '@/components/Coupon'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Component,
    children: [
      { path: '', component: Home },
      { path: '/shoplist', component: Shoplist },
      { path: '/coupon', component: Coupon },
      { path: '/balance', component: () => import('@/components/Balance') },
      { path: '/qian', component: () => import('@/components/Qian') }
    ]
  },
  {
    path: '/shop',
    component: Component,
    children: [
      { path: '', component: Shop },
      { path: '/shopdetails/:id', component: () => import('@/components/ShopDetails'), props: true }
    ]
  },
  {
    path: '/cart',
    name: 'cart',
    component: Cart
  },
  {
    path: '/user',
    component: Component,
    children: [
      { path: '', component: User },
      { path: '/orders/:type', props: true, component: () => import('@/components/Orders') },
      { path: '/address', component: () => import('@/components/Address') },
      { path: '/recharge', component: () => import('@/components/Recharge') },
      { path: '/collection', component: () => import('@/components/Collection') },
      { path: '/tracks', component: () => import('@/components/Tracks') },
      { path: '/payment', component: () => import('@/components/Payment') }
    ]
  },
  {
    path: '/search',
    component: Component,
    children: [
      { path: '', component: () => import('@/components/SearchData') },
      { path: 'list/:str', component: () => import('@/components/SearchShopList') }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  }
]

const router = new VueRouter({
  routes
})

export default router
